
var sql = require("../sql/sql");
var userSQL = require('../../config/Usersql');

class admin extends sql {
    constructor() {
        super();
    }

    checkPassword(user, success_callback, error_callback) {

        return new Promise((resolve, reject) => {
            if (typeof (user.username) === "undefined" || user.username === "")
                reject("用户名为空");
            else if (typeof (user.password) === "undefined" || user.username === "")
                reject("密码为空");
            
            this.query_sql(userSQL.user.queryLogin, [user.username,this.MD5(user.password)]).then(
                message => {
                    resolve(message);
                }, error => {
                    reject(error);
                }
            );
        });
        //return success_callback();
    }
}

module.exports = new admin();